package com.luocc.ccdemo.interceptor

import android.util.Log
import okhttp3.Interceptor
import okhttp3.Response

class LogInterceptor: Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val start = System.currentTimeMillis()
        Log.d(TAG, "request: ${request.url}")
        val response = chain.proceed(request)
        val end = System.currentTimeMillis()
        Log.d(TAG, "spend  : ${end - start} ms")
        return response
    }

    companion object {
        private const val TAG = "LC_HttpLog"
    }
}